#include <VolumeUnit.h>
#include <iostream>
#include <sstream>

#define OZTOTBSP    (3 * 4)
#define TSPTOTBSP   (4)
#define TBSPTOTBSP  (1)
using namespace std;

const UNIT_TYPE Volume_type;

VolumeUnit::VolumeUnit(const int factorOfBaseUnit): Unit(Volume_type,factorOfBaseUnit)
{
}


const Unit& VolumeUnit::getBaseUnit() const
{  
  return Tbsp();
}

const string VolumeUnit::getUnitString() const
{
    switch (factorOfBaseUnit)
    {
        case OZTOTBSP:	    
            return "Oz";            
      
        case TSPTOTBSP:	    
            return "Tsp"; 

        case TBSPTOTBSP:
	    return "Tbsp"; 

        default:	    
            return "Invalid";
     }	
}

string VolumeUnit::printEveryUnit(const PrintFormat& format, int amountLeftInBaseUnit) const
{   
   ostringstream os;
   if (format == Format_Big)
   {
       VolumeUnit(OZTOTBSP).printOneUnit(os, amountLeftInBaseUnit);
       VolumeUnit(TSPTOTBSP).printOneUnit(os, amountLeftInBaseUnit);
       VolumeUnit(TBSPTOTBSP).printOneUnit(os, amountLeftInBaseUnit);
   }
   else
   {
       VolumeUnit(TBSPTOTBSP).printOneUnit(os, amountLeftInBaseUnit);
   }

   return os.str();
}


const VolumeUnit& VolumeUnit::Oz()
{
  static VolumeUnit unit(OZTOTBSP);
  return unit;
}

const VolumeUnit& VolumeUnit::Tsp()
{
  static VolumeUnit unit(TSPTOTBSP);
  return unit;
}

const VolumeUnit& VolumeUnit::Tbsp()
{
  static VolumeUnit unit(TBSPTOTBSP);
  return unit;
}

